#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

using namespace cv;
using namespace std;

int main()
{
	//---生成标定图
	IplImage    *img;
	int chess_size = 500;
	int dx = 10;    //棋盘格大小，像素为单位
	int dy = 7;     //棋盘格数目
	img = cvCreateImage(cvSize(chess_size*dy, chess_size*dx), IPL_DEPTH_8U, 1);
	cvZero(img);
	int flag = 0;
	for (int i = 0; i < dx; i++)
	for (int j = 0; j < dy; j++)
	{
		flag = (i + j) % 2;
		if (flag == 0)
		{
			for (int m = i*chess_size; m < (i + 1)*chess_size; m++)
			for (int n = j*chess_size; n < (j + 1)*chess_size; n++)
				*(img->imageData + m*img->widthStep + n) = 255;
		}
	}
	cvSaveImage("标定图2.jpg", img);
	// 生成的棋盘格图保存在该工程目录下
	cvNamedWindow("cab", 1);
	cvShowImage("cab", img);
	char ch = cv::waitKey(0);
	if (ch == 27)
	{
		exit(0);
	}
	system("PAUSE");
	return 0;
	//---END生成标定图
}